#ifndef AGT_VEC2_H
#define AGT_VEC2_H

#include <iostream>
#include <string>
#include <sstream>

namespace agtk {

/** 2D Vector Class (generic type)
	@author Tom Savage
**/
template <class type> class Vec2 {
private:
	type v[2];
public:
	Vec2(void) {
		v[0] = 0;
		v[1] = 0;
	}

	Vec2(type valueX, type valueY) {
		v[0] = valueX;
		v[1] = valueY;
	}

	~Vec2(void) {
	}

	type Get(unsigned int index) {
		return v[index];
	}
	
	std::string GetStringFormat(void) {
		std::ostringstream oss (std::ostringstream::out);
		oss << "V2("<<v[0] << "," << v[1] << ")";
		return oss.str();
	}

	void Set(type valueX, type valueY) {
		v[0] = valueX;
		v[1] = valueY;
	}

	type Magnitude() const {
		return sqrt(v[0] * v[0] + v[1] * v[1]);
	}

	type MagnitudeSquared() const {
		return v[0] * v[0] + v[1] * v[1];
	}

	Vec2<type> Normalize() const {
		type m = sqrt(v[0] * v[0] + v[1] * v[1]);
		return Vec2(v[0] / m, v[1] / m);
	}
};

}
#endif